#!/bin/bash

cecho(){  # source: https://stackoverflow.com/a/53463162/2886168
    RED="\033[0;31m"
    GREEN="\033[0;32m"
    YELLOW="\033[0;33m"
    # ... ADD MORE COLORS
    NC="\033[0m" # No Color

    printf "${!1}${2} ${NC}\n"
}

cecho "GREEN" "Running RDMA Network Load Balancing Simulations (leaf-spine topology)"

# TOPOLOGY="leaf_spine_128_100G_OS2" # or, fat_k8_100G_OS2
# TOPOLOGY="fat_k8_100G_OS1"    # 128 servers, 100G 链路, 1:1收敛比
TOPOLOGY="fat_k8_100G_OS2"    # 256 servers, 100G 链路, 2:1收敛比
# TOPOLOGY="fat_k10_100G_OS1"    # 1024 servers, 100G 链路, 1:1收敛比
RUNTIME="0.1" # 0.1 second (traffic generation)


FLOWSIZE="100000000"

cecho "YELLOW" "\n----------------------------------"
cecho "YELLOW" "TOPOLOGY: ${TOPOLOGY}" 
cecho "YELLOW" "NETWORK LOAD: ${NETLOAD}" 
cecho "YELLOW" "TIME: ${RUNTIME}" 
cecho "YELLOW" "----------------------------------\n"

# Lossless RDMA
cecho "GREEN" "Run Lossless RDMA experiments..."
python3.7 lessflow_run.py --lb fecmp --pfc 1 --irn 0 --simul_time ${RUNTIME}  --topo ${TOPOLOGY} --flow_size ${FLOWSIZE} 2>&1 > /dev/null & 
sleep 5
python3.7 lessflow_run.py --lb lessflow --pfc 1 --irn 0 --simul_time ${RUNTIME}  --topo ${TOPOLOGY} --split_num 2 --flow_size ${FLOWSIZE}  2>&1 > /dev/null &
sleep 0.1
python3.7 lessflow_run.py --lb lessflow --pfc 1 --irn 0 --simul_time ${RUNTIME}  --topo ${TOPOLOGY} --split_num 4 --flow_size ${FLOWSIZE}  2>&1 > /dev/null &
sleep 0.1
python3.7 lessflow_run.py --lb lessflow --pfc 1 --irn 0 --simul_time ${RUNTIME}  --topo ${TOPOLOGY} --split_num 8 --flow_size ${FLOWSIZE}  2>&1 > /dev/null &
sleep 0.1
python3.7 lessflow_run.py --lb lessflow --pfc 1 --irn 0 --simul_time ${RUNTIME}  --topo ${TOPOLOGY} --split_num 16 --flow_size ${FLOWSIZE}  2>&1 > /dev/null &
sleep 0.1
python3.7 lessflow_run.py --lb lessflow --pfc 1 --irn 0 --simul_time ${RUNTIME}  --topo ${TOPOLOGY} --split_num 32 --flow_size ${FLOWSIZE}  2>&1 > /dev/null &
sleep 0.1
python3.7 lessflow_run.py --lb drill --pfc 1 --irn 0 --simul_time ${RUNTIME}  --topo ${TOPOLOGY} --flow_size ${FLOWSIZE} 2>&1 > /dev/null & 
sleep 0.1
python3.7 lessflow_run.py --lb conweave --pfc 1 --irn 0 --simul_time ${RUNTIME} --topo ${TOPOLOGY} --flow_size ${FLOWSIZE} 2>&1 > /dev/null &
sleep 0.1


# IRN RDMA
# cecho "GREEN" "Run IRN RDMA experiments..."
# sleep 0.1
# python3.7 lessflow_run.py --lb drill --pfc 0 --irn 1 --simul_time ${RUNTIME}  --topo ${TOPOLOGY} --flow_size ${FLOWSIZE} 2>&1 > /dev/null & 


# cecho "GREEN" "Runing all in parallel. Check the processors running on background!"